import 'dart:developer';

import 'package:easy_refresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'package:sports_new/entity/king/king_history_entity.dart';
import 'package:sports_new/server/api/king_api.dart';
import 'package:sports_new/utils/utils.dart';

import '../../entity/other/play_entity.dart';

class KingHistoryLogic extends GetxController {
  List<KingHistoryEntity>? data;
  List<String> betWin = [];
  List<String> betPoints = [];
  int _pageIndex = 1;
  EasyRefreshController refreshController = EasyRefreshController(
      controlFinishLoad: true);

  @override
  void onReady() {
    getData();
    super.onReady();
  }

  Future getData() async {
    data = await KingApi.getKingHistory(_pageIndex, 15);
    update();
  }

  Future loadMore() async{
    _pageIndex += 1;
    data?.addAll(await KingApi.getKingHistory(_pageIndex, 15));
    refreshController.finishLoad(
      (data?.length ?? 0) < _pageIndex*15?
      IndicatorResult.noMore:IndicatorResult.success);
    update();
  }
}